<template>
	<view>
		<view class="goods_list">
			<view class="goods_item" v-for="(item, index) in goodsList" 
			:key="index" @click="goodsInfo(item)">
				<image :src="item.show.img"></image>
				<view class="price">
					<text>￥{{item.price}} </text>
					<text>{{item.orgPrice}}</text>
				</view>
				<text>
					{{item.title}}
				</text>
			</view>
			
		</view>
				
	</view>
</template>

<script>
	export default {
		props:{
			goodsList: {
				type: Array,
				default: []
			},
			
		},
		methods: {
			goodsInfo(item) {
				//创建窗体通信
				uni.$emit('oneItem', item)
				uni.navigateTo({
					url:'../../pages/goods/goodsdetail/goodsdetail'
					
				})
			}
		}
	}
</script>

<style lang="scss">
	.goods_list {
		display: flex;
		padding: 0 8rpx;
		flex-wrap: wrap;
		justify-content: space-around;
		view:nth-of-type(2n) {
			// padding: 0 10rpx;
		}
		.goods_item {
			width: 48%;
			margin-bottom: 10px;
			background-color: #fff;
			image{
				display: block;
				margin: 0 auto;
				width: 100%;
				height: 250px;
			}
			>text {
				display: block;
				width: 100%;
				color: #666;
				font-size: 28rpx;
				padding: 10px 5px;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
		}
		
	}
	.price {
		text:nth-of-type(2n-1){
			color: red;
			font-size: 20px;
			margin-left: 10px;
		}
		text:nth-of-type(2n){
			color: $uni-text-color-grey;
			text-decoration: line-through;
			font-size: 12px;
			margin-left: 10px;
			
		}
	}
	
</style>
